<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Class template basic_custom_mapping</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../../index.html" title="Chapter 1. Boost.Log v2">
<link rel="up" href="../../../sinks.html#header.boost.log.sinks.attribute_mapping_hpp" title="Header &lt;boost/log/sinks/attribute_mapping.hpp&gt;">
<link rel="prev" href="asynchronous_sink/scoped_flag.html" title="Class scoped_flag">
<link rel="next" href="basic_direct_mapping.html" title="Class template basic_direct_mapping">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td></tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="asynchronous_sink/scoped_flag.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../../sinks.html#header.boost.log.sinks.attribute_mapping_hpp"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="basic_direct_mapping.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="refentry">
<a name="boost.log.sinks.basic_custom_mapping"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2><span class="refentrytitle">Class template basic_custom_mapping</span></h2>
<p>boost::log::sinks::basic_custom_mapping — Customizable mapping. </p>
</div>
<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../../../sinks.html#header.boost.log.sinks.attribute_mapping_hpp" title="Header &lt;boost/log/sinks/attribute_mapping.hpp&gt;">boost/log/sinks/attribute_mapping.hpp</a>&gt;

</span><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> MappedT<span class="special">,</span> <span class="keyword">typename</span> AttributeValueT <span class="special">=</span> <span class="keyword">int</span><span class="special">&gt;</span> 
<span class="keyword">class</span> <a class="link" href="basic_custom_mapping.html" title="Class template basic_custom_mapping">basic_custom_mapping</a> <span class="special">:</span>
  <span class="keyword">public</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">log</span><span class="special">::</span><span class="identifier">sinks</span><span class="special">::</span><span class="identifier">basic_mapping</span><span class="special">&lt;</span> <span class="identifier">MappedT</span> <span class="special">&gt;</span>
<span class="special">{</span>
<span class="keyword">public</span><span class="special">:</span>
  <span class="comment">// types</span>
  <span class="keyword">typedef</span> <span class="identifier">AttributeValueT</span>        <a name="boost.log.sinks.basic_custom_mapping.attribute_value_type"></a><span class="identifier">attribute_value_type</span><span class="special">;</span>  <span class="comment">// Attribute contained value type. </span>
  <span class="keyword">typedef</span> <span class="identifier">base_type</span><span class="special">::</span><span class="identifier">mapped_type</span> <a name="boost.log.sinks.basic_custom_mapping.mapped_type"></a><span class="identifier">mapped_type</span><span class="special">;</span>           <span class="comment">// Mapped value type. </span>

  <span class="comment">// <a class="link" href="basic_custom_mapping.html#boost.log.sinks.basic_custom_mappingconstruct-copy-destruct">construct/copy/destruct</a></span>
  <span class="keyword">explicit</span> <a class="link" href="basic_custom_mapping.html#idm45961919238800-bb"><span class="identifier">basic_custom_mapping</span></a><span class="special">(</span><span class="identifier">attribute_name</span> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">,</span> <span class="identifier">mapped_type</span> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>

  <span class="comment">// <a class="link" href="basic_custom_mapping.html#idm45961919247072-bb">public member functions</a></span>
  <span class="identifier">mapped_type</span> <a class="link" href="basic_custom_mapping.html#idm45961919246512-bb"><span class="keyword">operator</span><span class="special">(</span><span class="special">)</span></a><span class="special">(</span><span class="identifier">record_view</span> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="identifier">implementation_defined</span> <a class="link" href="basic_custom_mapping.html#idm45961919242832-bb"><span class="keyword">operator</span><span class="special">[</span><span class="special">]</span></a><span class="special">(</span><span class="identifier">attribute_value_type</span> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
<span class="special">}</span><span class="special">;</span></pre></div>
<div class="refsect1">
<a name="idm46846459550368"></a><h2>Description</h2>
<p>The class allows to setup a custom mapping between an attribute and native values. The mapping should be initialized similarly to the standard <code class="computeroutput">map</code> container, by using indexing operator and assignment.</p>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../doc/src/images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>Unlike many other components of the library, exact type of the attribute value must be specified in the template parameter <code class="computeroutput">AttributeValueT</code>. Type sequences are not supported. </p></td></tr>
</table></div>
<p>
</p>
<div class="refsect2">
<a name="idm46846459547168"></a><h3>
<a name="boost.log.sinks.basic_custom_mappingconstruct-copy-destruct"></a><code class="computeroutput">basic_custom_mapping</code> 
        public
       construct/copy/destruct</h3>
<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
<pre class="literallayout"><span class="keyword">explicit</span> <a name="idm45961919238800-bb"></a><span class="identifier">basic_custom_mapping</span><span class="special">(</span><span class="identifier">attribute_name</span> <span class="keyword">const</span> <span class="special">&amp;</span> name<span class="special">,</span> 
                              <span class="identifier">mapped_type</span> <span class="keyword">const</span> <span class="special">&amp;</span> default_value<span class="special">)</span><span class="special">;</span></pre>
<p>Constructor</p>
<p>
</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term">Parameters:</span></p></td>
<td><div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><code class="computeroutput">default_value</code></span></p></td>
<td><p>The default native value that is returned if the conversion cannot be performed </p></td>
</tr>
<tr>
<td><p><span class="term"><code class="computeroutput">name</code></span></p></td>
<td><p>Attribute name </p></td>
</tr>
</tbody>
</table></div></td>
</tr></tbody>
</table></div>
</li></ol></div>
</div>
<div class="refsect2">
<a name="idm46846459530880"></a><h3>
<a name="idm45961919247072-bb"></a><code class="computeroutput">basic_custom_mapping</code> public member functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><span class="identifier">mapped_type</span> <a name="idm45961919246512-bb"></a><span class="keyword">operator</span><span class="special">(</span><span class="special">)</span><span class="special">(</span><span class="identifier">record_view</span> <span class="keyword">const</span> <span class="special">&amp;</span> rec<span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>
<p>Extraction operator. Extracts the attribute value and attempts to map it onto the native value.</p>
<p>

</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term">Parameters:</span></p></td>
<td><div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><code class="computeroutput">rec</code></span></p></td>
<td><p>A log record to extract value from </p></td>
</tr></tbody>
</table></div></td>
</tr>
<tr>
<td><p><span class="term">Returns:</span></p></td>
<td><p>A mapped value, if mapping was successful, or the default value if mapping did not succeed. </p></td>
</tr>
</tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="identifier">implementation_defined</span> <a name="idm45961919242832-bb"></a><span class="keyword">operator</span><span class="special">[</span><span class="special">]</span><span class="special">(</span><span class="identifier">attribute_value_type</span> <span class="keyword">const</span> <span class="special">&amp;</span> key<span class="special">)</span><span class="special">;</span></pre>
<p>Insertion operator</p>
<p>

</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term">Parameters:</span></p></td>
<td><div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><code class="computeroutput">key</code></span></p></td>
<td><p>Attribute value to be mapped </p></td>
</tr></tbody>
</table></div></td>
</tr>
<tr>
<td><p><span class="term">Returns:</span></p></td>
<td><p>An object of unspecified type that allows to insert a new mapping through assignment. The <span class="emphasis"><em>key</em></span> argument becomes the key attribute value, and the assigned value becomes the mapped native value. </p></td>
</tr>
</tbody>
</table></div>
</li>
</ol></div>
</div>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2007-2021 Andrey Semashev<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>).
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="asynchronous_sink/scoped_flag.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../../sinks.html#header.boost.log.sinks.attribute_mapping_hpp"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="basic_direct_mapping.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
